<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2017/11/2
 * Time: 14:56
 */
namespace app\inter\model;

use \think\Model;
use think\Db;
class OrderModel extends InterBase
{
    public function getOrderInfo($map=array(),$field='*',$flag=true,$order='b.id desc',$page=1,$limit=10,$config='')
    {
        $config = $config?:$this->config;
        return $flag ? Db::connect($config)->name('order b')
            ->join(config('inner_db')['database'].'.xm_passenger c','c.passenger_id=b.passenger_id','LEFT')
            ->where($map)->field($field)->page($page,$limit)->order($order)->select()
            :Db::connect($config)->name('order b')
                ->join(config('inner_db')['database'].'.xm_passenger c','c.passenger_id=b.passenger_id','LEFT')
                ->where($map)->field($field)->order($order)->find();
    }

    public function addOrder($data=array())
    {
        return Db::table('inter_order')->insertGetId($data);
    }

    public function addOrderAll($data=array())
    {
        return Db::table('inter_order')->insertAll($data);
    }

    public function orderCount($map)
    {
        return Db::table('inter_order')->where($map)->count();
    }
}